-
Notifications
You must be signed in to change notification settings - Fork 99
fwserver: add list resources to GetProviderSchema
#1152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
GetProviderSchema
da1aba6 to
83f0604
Compare
c57458a to
586bdca
Compare
1da956e to
70aac24
Compare
586bdca to
f971285
Compare
70aac24 to
d6776b3
Compare
485abb7 to
4dd9564
Compare
4dd9564 to
7a0dfb3
Compare
b30df31 to
be455ea
Compare
be455ea to
7691bb8
Compare
austinvalle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as a first go, left some considerations for future PRs
| continue | ||
| } | ||
|
|
||
| if _, ok := s.resourceFuncs[typeName]; !ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is s.resourceFuncs guaranteed to be populated at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a roundabout way, yes. The fwserver implementations of GetMetadata and GetProviderSchema both call Server.ResourceFuncs to prime that cache before Server.ListResourceFuncs.
There's room for improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we change this to s.ResourceFuncs(ctx)[typeName] ...
| // also validated. | ||
| func (s *Server) ListResourceSchemas(ctx context.Context) (map[string]fwschema.Schema, diag.Diagnostics) { | ||
| listResourceSchemas := make(map[string]fwschema.Schema) | ||
| listResourceFuncs, diags := s.ListResourceFuncs(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will give us the list resource implementations actually defined in ListResources(), but couldn't there also be implementations in Resources() as well? Potentially conflicting 👀
same thought for metadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My current thinking on this is: Framework only needs to look at ListResources().
If a provider type implements both resource.Resource and list.ListResource, then they add a NewMyResource function in two places: Resources() and ListResources().
There's room for improvement...
| Path: path.Root(attributeName), | ||
| } | ||
|
|
||
| diags.Append(fwschema.IsReservedResourceAttributeName(req.Name, req.Path)...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a reminder (since it's also relevant for state storage), we should double check if there are any additional fields that should be protect from shadowing that aren't the same as managed resources.
For example, state_store blocks will only need to ensure there is no provider attribute in the schema.
austinvalle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Description
To merge after #1151. This pull request adds list resource metadata to the protocol-independent framework server implementation of
GetProviderSchema.For a focused start, I have defined
list.Schema.StringAttributeand no other attribute types or block types. Then, the remaining schema definition can follow in another focused pull request.Rollback Plan
Changes to Security Controls
None